jQuery(document).ready(function(){
    jQuery('#_mail_type').combobox({  
        mulitple: false,
        editable: false,
        panelHeight:100
    }); 



    jQuery('#_mail_group').combobox({  
        mulitple: false,    
        panelHeight:100    
    }); 

    var form=jQuery('form').first();
    var cancel=jQuery('#submitControl .button')[1];        
    form.removeAttr('onsubmit').submit(function(event){
        if(form.valid()){
            $.ajax({
                url:'index.php',
                dataType:'html',
                async:false,
                data: $(form).serialize(),
                success:function(data, textStatus, jqXHR){
                    if(data=="OK")
                        {
                        window.opener._load_manage_mail_reload(); 
                        window.close();
                    }
                    else if(data=="block")
                        {
                        alert("This email has been block by administrator!");
                    }
                    else
                        {
                        alert("Not success");
                    }
                }
            });
        }

        event.preventDefault();

    });
    jQuery(cancel).removeAttr('onClick').click(function(event){
        window.close();
        event.preventDefault();
    });

   /* var uploader = new qq.FileUploader({
        element: document.getElementById('_mail_addAttachment'),
        multiple: false, 
        uploadButtonText:"Select file to attach",
        dragText:"Drag file into this area",
        allowedExtensions: ["png","jpg","gif","pdf","zip","txt","doc","docx","xls","xslx"],
        onSubmit: function(id, name){
            _tmp_id=jQuery('#tmp_id').val();
            _id=jQuery('#id').val();
            if(!_tmp_id)
               _tmp_id=0;               
            
            uploader.setParams({ 
                id: _id,
                tmp_id:_tmp_id,
                ajax_action: 1,
                module: "mailsystemmodule",
                action: "mails_manage_upload",
                
            });
        },
        onComplete: function (id, fileName, responseJSON){
            if (responseJSON.file_path != undefined)
                {
                jQuery("#files_attach_list").append(responseJSON.file_path+'<br>');
            }
        },
        action: '/index.php'
    });*/
});